<template>
  <div>
    <div class="flex flex-col md:flex-row md:items-center md:justify-between mb-6">
      <h1 class="text-2xl font-bold text-gray-900">员工管理</h1>
      <div class="mt-4 md:mt-0 flex space-x-3">
        <div class="relative">
          <input type="text" placeholder="搜索员工..." class="w-full md:w-64 pl-10 pr-4 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent">
          <i class="fa fa-search absolute left-3 top-3 text-gray-400"></i>
        </div>
        <button class="bg-blue-500 hover:bg-blue-600 text-white px-4 py-2 rounded-md transition">
          <i class="fa fa-plus mr-2"></i>添加员工
        </button>
      </div>
    </div>
    
    <div class="bg-white rounded-lg shadow-md overflow-hidden">
      <div class="overflow-x-auto">
        <table class="min-w-full divide-y divide-gray-200">
          <thead class="bg-gray-50">
            <tr>
              <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">头像</th>
              <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">姓名</th>
              <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">职位</th>
              <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">工号</th>
              <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">电话</th>
              <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">状态</th>
              <th scope="col" class="px-6 py-3 text-right text-xs font-medium text-gray-500 uppercase tracking-wider">操作</th>
            </tr>
          </thead>
          <tbody class="bg-white divide-y divide-gray-200">
            <tr v-for="(employee, index) in employees" :key="index">
              <td class="px-6 py-4 whitespace-nowrap">
                <div class="flex items-center">
                  <div class="h-10 w-10 rounded-full overflow-hidden">
                    <img :src="employee.avatar" :alt="employee.name" class="h-full w-full object-cover">
                  </div>
                </div>
              </td>
              <td class="px-6 py-4 whitespace-nowrap">
                <div class="text-sm font-medium text-gray-900">{{ employee.name }}</div>
              </td>
              <td class="px-6 py-4 whitespace-nowrap">
                <span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full" :class="employee.position === '服务员' ? 'bg-blue-100 text-blue-800' : employee.position === '厨师' ? 'bg-red-100 text-red-800' : employee.position === '收银员' ? 'bg-purple-100 text-purple-800' : 'bg-gray-100 text-gray-800'">
                  {{ employee.position }}
                </span>
              </td>
              <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
                {{ employee.employeeId }}
              </td>
              <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
                {{ employee.phone }}
              </td>
              <td class="px-6 py-4 whitespace-nowrap">
                <span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full" :class="employee.status === '在职' ? 'bg-green-100 text-green-800' : 'bg-gray-100 text-gray-800'">
                  {{ employee.status }}
                </span>
              </td>
              <td class="px-6 py-4 whitespace-nowrap text-right text-sm font-medium">
                <button class="text-indigo-600 hover:text-indigo-900 mr-3">编辑</button>
                <button class="text-red-600 hover:text-red-900">删除</button>
              </td>
            </tr>
          </tbody>
        </table>
      </div>
      <div class="bg-white px-4 py-3 flex items-center justify-between border-t border-gray-200 sm:px-6">
        <div class="hidden sm:flex-1 sm:flex sm:items-center sm:justify-between">
          <div>
            <p class="text-sm text-gray-700">
              显示 <span class="font-medium">1</span> 到 <span class="font-medium">5</span> 项，共 <span class="font-medium">12</span> 项
            </p>
          </div>
          <div>
            <nav class="relative z-0 inline-flex rounded-md shadow-sm -space-x-px" aria-label="Pagination">
              <a href="#" class="relative inline-flex items-center px-2 py-2 rounded-l-md border border-gray-300 bg-white text-sm font-medium text-gray-500 hover:bg-gray-50">
                <span class="sr-only">上一页</span>
                <i class="fa fa-chevron-left h-5 w-5"></i>
              </a>
              <a href="#" aria-current="page" class="z-10 bg-indigo-50 border-indigo-500 text-indigo-600 relative inline-flex items-center px-4 py-2 border text-sm font-medium">1</a>
              <a href="#" class="bg-white border-gray-300 text-gray-500 hover:bg-gray-50 relative inline-flex items-center px-4 py-2 border text-sm font-medium">2</a>
              <a href="#" class="bg-white border-gray-300 text-gray-500 hover:bg-gray-50 relative inline-flex items-center px-4 py-2 border text-sm font-medium">3</a>
              <a href="#" class="relative inline-flex items-center px-2 py-2 rounded-r-md border border-gray-300 bg-white text-sm font-medium text-gray-500 hover:bg-gray-50">
                <span class="sr-only">下一页</span>
                <i class="fa fa-chevron-right h-5 w-5"></i>
              </a>
            </nav>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref } from 'vue'

const employees = ref([
  {
    id: 1,
    name: '张三',
    avatar: 'https://picsum.photos/200/200?person=1',
    position: '服务员',
    employeeId: 'EMP2023001',
    phone: '13800138001',
    status: '在职'
  },
  {
    id: 2,
    name: '李四',
    avatar: 'https://picsum.photos/200/200?person=2',
    position: '厨师',
    employeeId: 'EMP2023002',
    phone: '13900139002',
    status: '在职'
  },
  {
    id: 3,
    name: '王五',
    avatar: 'https://picsum.photos/200/200?person=3',
    position: '收银员',
    employeeId: 'EMP2023003',
    phone: '13700137003',
    status: '在职'
  },
  {
    id: 4,
    name: '赵六',
    avatar: 'https://picsum.photos/200/200?person=4',
    position: '服务员',
    employeeId: 'EMP2023004',
    phone: '13600136004',
    status: '在职'
  },
  {
    id: 5,
    name: '钱七',
    avatar: 'https://picsum.photos/200/200?person=5',
    position: '厨师',
    employeeId: 'EMP2023005',
    phone: '13500135005',
    status: '已离职'
  }
])
</script>    